package pe.com.bbva.ge.persistencia.orm.hibernate.utileria;

import java.lang.annotation.*;
import java.io.Serializable;
import org.hibernate.Criteria;
import org.hibernate.FetchMode;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.Session;
import org.hibernate.criterion.CriteriaSpecification;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Projection;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.impl.CriteriaImpl;
import org.hibernate.transform.ResultTransformer;

/** @author hectorsaira
 * 
 * @pdOid ed799240-9bb0-40a5-a537-fade3e03f6ab */
@SuppressWarnings("serial")
public class Busqueda implements java.io.Serializable {
   /** @pdOid e7bbae02-bd4f-4524-aea0-55fc4e0f58da */
   private final CriteriaImpl impl;
   /** @pdOid 98612bd0-1d6b-425d-b5f7-277488d5caab */
   private final Criteria criteria;
   /** @pdOid 25f2814e-6880-4fc3-b616-cc23e58f036f */
   private int maxResults = -1;
   /** @pdOid 3cd0d640-ffae-4af6-ac7f-6ec5ef05f33b */
   private int firstResult = 0;
   
   /** @param entityName
    * @pdOid 9327c241-e31d-4d3e-812a-8d2acf3f6d8e */
   protected Busqueda(String entityName) {
   	impl = new CriteriaImpl(entityName, null);
   	criteria = impl;
   }
   
   /** @param entityName 
    * @param alias
    * @pdOid 5d98fdda-d01b-4414-a485-eb09866dc9b9 */
   protected Busqueda(String entityName, String alias) {
   	impl = new CriteriaImpl(entityName, alias, null);
   	criteria = impl;
   }
   
   /** @param impl 
    * @param criteria
    * @pdOid 6e8f6b78-910b-4e49-b295-2c55aedf3860 */
   protected Busqueda(CriteriaImpl impl, Criteria criteria) {
   	this.impl = impl;
   	this.criteria = criteria;
   }
   
   /** @pdOid c1ca3c6e-eb34-485b-a4bd-35f1971e1a93 */
   public int getMaxResults() {
   	return maxResults;
   }
   
   /** @param maxResults
    * @pdOid aaa90a1c-218f-4cb4-8c84-99416612cda1 */
   public void setMaxResults(int maxResults) {
   	this.maxResults = maxResults;
   }
   
   /** @pdOid 5e3db3c9-dfce-4b95-b59c-9701049d3739 */
   public int getFirstResult() {
   	return firstResult;
   }
   
   /** @param firstResult
    * @pdOid 2ed3d25d-a6a5-44d0-8426-71549bea2313 */
   public void setFirstResult(int firstResult) {
   	this.firstResult = firstResult;
   }
   
   /** @param session
    * @pdOid 6ff724b2-13ae-4446-81b7-650e638a1624 */
   public Criteria getExecutableCriteria(Session session) {
   	impl.setSession((SessionImplementor) session);
   	return impl;
   }
   
   /** @param entityName
    * @pdOid 6376dd53-cd4f-4f0a-aa72-3acbb46df73b */
   public static Busqueda forEntityName(String entityName) {
   	return new Busqueda(entityName);
   }
   
   /** @param entityName 
    * @param alias
    * @pdOid 8ad3364b-803f-4f2f-97fa-61599b9241f5 */
   public static Busqueda forEntityName(String entityName, String alias) {
   	return new Busqueda(entityName, alias);
   }
   
   /** @param clazz
    * @pdOid 03ff0519-2cdd-4a7e-9174-9dbd5419f602 */
   @SuppressWarnings("rawtypes")
   public static Busqueda forClass(Class clazz) {
   	return new Busqueda(clazz.getName());
   }
   
   /** @param clazz 
    * @param alias
    * @pdOid 5cbac057-e890-40e6-9c0c-d25a72176266 */
   @SuppressWarnings("rawtypes")
   public static Busqueda forClass(Class clazz, String alias) {
   	return new Busqueda(clazz.getName(), alias);
   }
   
   /** @param criterion
    * @pdOid a44c16d6-1507-4ec6-aa03-751dbea4c46f */
   public Busqueda add(Criterion criterion) {
   	criteria.add(criterion);
   	return this;
   }
   
   /** @param order
    * @pdOid d4deba25-a5f6-4ee4-90bb-7f91404d6a05 */
   public Busqueda addOrder(Order order) {
   	criteria.addOrder(order);
   	return this;
   }
   
   /** @param associationPath 
    * @param alias
    * @exception HibernateException
    * @pdOid 5dc63747-e7cd-4bfd-b7b9-c838d2d97512 */
   public Busqueda createAlias(String associationPath, String alias) throws HibernateException 		{
   	criteria.createAlias(associationPath, alias);
   	return this;
   }
   
   /** @param associationPath 
    * @param alias
    * @exception HibernateException
    * @pdOid 55ce046c-9d73-4b91-9d19-ec73074ad81c */
   public Busqueda createCriteria(String associationPath, String alias) throws HibernateException 		{
   	return new Busqueda(impl, criteria.createCriteria(associationPath,
   			alias));
   }
   
   /** @param associationPath
    * @exception HibernateException
    * @pdOid 4c247c77-8f30-409a-b62d-edff396b64bb */
   public Busqueda createCriteria(String associationPath) throws HibernateException 		{
   	return new Busqueda(impl, criteria.createCriteria(associationPath));
   }
   
   /** @pdOid af08d72d-bee6-40aa-937d-115954ce40d1 */
   public String getAlias() {
   	return criteria.getAlias();
   }
   
   /** @param associationPath 
    * @param mode
    * @exception HibernateException
    * @pdOid 9630485c-d160-4da5-bab5-fd8d93185bb9 */
   public Busqueda setFetchMode(String associationPath, FetchMode mode) throws HibernateException 		{
   	criteria.setFetchMode(associationPath, mode);
   	return this;
   }
   
   /** @param projection
    * @pdOid 9443927a-e6e0-4ab3-b2c3-d81471cbc8fa */
   public Busqueda setProjection(Projection projection) {
   	criteria.setProjection(projection);
   	return this;
   }
   
   /** @param resultTransformer
    * @pdOid c9d91e7c-051b-4fcf-b656-a768c3292d67 */
   public Busqueda setResultTransformer(ResultTransformer resultTransformer) {
   	criteria.setResultTransformer(resultTransformer);
   	return this;
   }
   
   /** @pdOid b1155bf3-9708-48b1-84a6-a9b67b5d88c3 */
   @Override
   public String toString() {
   	return criteria.toString();
   }
   
   /** @param associationPath 
    * @param alias 
    * @param joinType
    * @exception HibernateException
    * @pdOid 55a72131-1be7-4f57-88d5-55b0a3088810 */
   public Busqueda createAlias(String associationPath, String alias, int joinType) throws HibernateException 		{
   	criteria.createAlias(associationPath, alias, joinType);
   	return this;
   }
   
   /** @param associationPath 
    * @param joinType
    * @exception HibernateException
    * @pdOid d7872392-a2fb-4b7f-a4c5-ca9ba2b51512 */
   public Busqueda createCriteria(String associationPath, int joinType) throws HibernateException 		{
   	return new Busqueda(impl, criteria.createCriteria(associationPath,
   			joinType));
   }
   
   /** @param associationPath 
    * @param alias 
    * @param joinType
    * @exception HibernateException
    * @pdOid fe37d6a3-d676-4930-a149-8adaa9296f5b */
   public Busqueda createCriteria(String associationPath, String alias, int joinType) throws HibernateException 		{
   	return new Busqueda(impl, criteria.createCriteria(associationPath,
   			alias, joinType));
   }
   
   /** @param comment
    * @pdOid 54d2a7c4-4a25-4055-a0a4-33bcc193eb51 */
   public Busqueda setComment(String comment) {
   	criteria.setComment(comment);
   	return this;
   }
   
   /** @param lockMode
    * @pdOid 4c2eeee1-505b-4cc3-b97f-348794509632 */
   public Busqueda setLockMode(LockMode lockMode) {
   	criteria.setLockMode(lockMode);
   	return this;
   }
   
   /** @param alias 
    * @param lockMode
    * @pdOid c2edd806-c0a4-49b2-814a-597e5e66dd51 */
   public Busqueda setLockMode(String alias, LockMode lockMode) {
   	criteria.setLockMode(alias, lockMode);
   	return this;
   }

}